import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsArray, IsOptional, ValidationArguments } from 'class-validator'
import { CreateRoleDto } from './create-role.dto'

export class UpdateRoleDto extends PartialType(CreateRoleDto) {
  // @ApiProperty({ description: '角色id' })
  // @IsNotEmpty({ message: '角色id不能为空' })
  // @IsInt({ message: '角色id必须是数字' })
  // roleId: number

  @ApiProperty({ description: '菜单id', required: false })
  @IsArray({
    message(args: ValidationArguments) {
      if (args.value?.length === 0) {
        return `菜单IDs必须是数组`
      }
    },
  })
  @IsOptional()
  menuIds: number[]

  @ApiProperty({ description: '权限按钮id', required: false })
  @IsArray({
    message(args: ValidationArguments) {
      if (args.value?.length === 0) {
        return `权限按钮IDs必须是数组`
      }
    },
  })
  @IsOptional()
  buttons: number[]
}
